package com.linq.cool.file.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author: yqlin
 * @Date: 2020/12/29 23:58
 * @Description: Oss配置 当项目已启动，spring接口，spring加载之后，执行接口一个方法
 * @Version: 1.0.0
 */
@Component
public class OssProperties implements InitializingBean {
    /**
     * 定义公开静态常量
     */
    public static String OSS_END_POINT;
    public static String OSS_ACCESS_KEY;
    public static String OSS_SECRET_KEY;
    public static String OSS_BUCKET_NAME;
    public static String OSS_BUCKET_DOMAIN;
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.file.key-id}")
    private String keyId;
    @Value("${aliyun.oss.file.key-secret}")
    private String keySecret;
    @Value("${aliyun.oss.file.bucket-name}")
    private String bucketName;
    @Value("${aliyun.oss.file.bucket-domain}")
    private String bucketDomain;

    @Override
    public void afterPropertiesSet() throws Exception {
        OSS_END_POINT = endpoint;
        OSS_ACCESS_KEY = keyId;
        OSS_SECRET_KEY = keySecret;
        OSS_BUCKET_NAME = bucketName;
        OSS_BUCKET_DOMAIN = bucketDomain;
    }
}
